/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity.tta;

import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 *
 * @author Chen Zhe
 */

/**
 * TTA conventions of type in StrLongRecord and StrDblRecord:
 *  types in StrLongRecord:  MonthSale,MonthSurvey,AgeGroupSale,CountrySale
 *  types in StrLongRecord: MonthReservation, MonthAdClick,AgeGroupReservation,CountryReservation
 * @author Chen Zhe
 */
@Entity
public class DataModel implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    @Temporal(javax.persistence.TemporalType.DATE) 
    protected Calendar time_stamp;
    protected int[][] cluster;
    
    //the countries list should be updated from the customer account registration side
    protected String[] countriesList;
    protected String[] ageGroupsList;
    
    //types in StrDblRecords: MonthSale,AgeGroupSale,CountrySale
    @OneToMany (cascade = {CascadeType.PERSIST})
    private StrDblRecord strDblRecords;
    
    //types in StrLongRecord: MonthReservation,AgeGroupReservation,CountryReservation
    @OneToMany (cascade = {CascadeType.PERSIST})
    private StrLongRecord strLongRecords;
    
    
    public DataModel() {}
    
    public void create() {
        countriesList = new String[]{"China", "Singapore", "Malyasia", "Australia", "Japan", "Canada"};
        ageGroupsList = new String[]{"15-25", "26-35", "36-49", "50-60", "61-100"};
        cluster = new int[countriesList.length][ageGroupsList.length];
        time_stamp = Calendar.getInstance();
        time_stamp.set(Calendar.YEAR, 1000);
        //initialize the cluster data mining structure
        for (int i = 0; i < cluster.length; i++) {
            for (int j = 0; j < cluster[0].length; j++) {
                cluster[i][j]=0;
            }
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Calendar getTime_stamp() {
        return time_stamp;
    }

    public void setTime_stamp(Calendar time_stamp) {
        this.time_stamp = time_stamp;
    }

    public String[] getCountriesList() {
        return countriesList;
    }

    public void setCountriesList(String[] countriesList) {
        this.countriesList = countriesList;
    }

    public String[] getAgeGroupsList() {
        return ageGroupsList;
    }

    public void setAgeGroupsList(String[] ageGroupsList) {
        this.ageGroupsList = ageGroupsList;
    }

    public void updateCluster() {
    }

    public int[][] getCluster() {
        return cluster;
    }

    public void setCluster(int[][] cluster) {
        this.cluster = cluster;
    }

    /**
     * @return the strDblRecords
     */
    public StrDblRecord getStrDblRecords() {
        return strDblRecords;
    }

    /**
     * @param strDblRecords the strDblRecords to set
     */
    public void setStrDblRecords(StrDblRecord strDblRecords) {
        this.strDblRecords = strDblRecords;
    }

    /**
     * @return the strLongRecords
     */
    public StrLongRecord getStrLongRecords() {
        return strLongRecords;
    }

    /**
     * @param strLongRecords the strLongRecords to set
     */
    public void setStrLongRecords(StrLongRecord strLongRecords) {
        this.strLongRecords = strLongRecords;
    }

    
}
